package com.taijihuabao.modules.service.impl;

import com.taijihuabao.modules.entity.BaseClockEntity;
import com.taijihuabao.modules.entity.BaseTypeEntity;
import com.taijihuabao.modules.mapper.BaseClockMapper;
import com.taijihuabao.modules.mapper.BaseTypeMapper;
import com.taijihuabao.modules.model.baseclock.vo.BaseTypeVO;
import com.taijihuabao.modules.service.BaseClockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @title: BaseClockServiceImpl
 * @Author luoxianan
 * @Date: 2022/1/7 10:59
 * @Version 1.0
 */
@Service("BaseClockService")
public class BaseClockServiceImpl implements BaseClockService {
    @Autowired
    private BaseClockMapper baseClockMapper;
    @Autowired
    private BaseTypeMapper baseTypeMapper;

    /**
     * 根据码表类型查询
     * @param typeName
     * @return
     */
    @Override
    public BaseTypeVO selectByTypeName(String typeName) {
        return baseTypeMapper.selectByTypeName(typeName);
    }

    /**
     * 增加码表类型
     * @param baseTypeEntity
     */
    @Override
    public BaseTypeEntity insertBaseType(BaseTypeEntity baseTypeEntity) {
        baseTypeMapper.insertBaseType(baseTypeEntity);
        BaseTypeEntity baseTypeEntity1 = new BaseTypeEntity();
        baseTypeEntity1.setId(baseTypeEntity.getId());
        baseTypeEntity1.setTypeName(baseTypeEntity.getTypeName());
        return baseTypeEntity1;
    }

    /**
     * 根据码表类型查询码值
     * @param typeId
     * @return
     */
    @Override
    public List<BaseClockEntity> selectAllByTypeId(Long typeId) {
        return baseClockMapper.selectAllByTypeId(typeId);
    }

    /**
     * 根据码表类型修改码值
     * @param baseClockEntity
     */
    @Override
    public void updateByTypeId(BaseClockEntity baseClockEntity) {
        baseClockMapper.updateByTypeId(baseClockEntity);
    }

    /**
     * 增加码值
     * @param baseClockEntity
     */
    @Override
    public void insertAll(BaseClockEntity baseClockEntity) {
        baseClockMapper.insertAll(baseClockEntity);
    }
}
